package com.sfc.sdsr.common.model;

import java.io.Serializable;
import java.util.UUID;

public class Address implements IFileDao, Serializable, Comparable<Address> {
	
	private static final long serialVersionUID = 0xDEADBEEFBABE0001L;

	private UUID addressUuid;
	private int houseNumber;
	private String streetName;
	private String modifier;
	private String city;
	private String state;
	private int zip;
	private String commonName;
	private String extraString;

	public UUID getAddressUuid() {
		return addressUuid;
	}

	public void setAddressUuid(UUID addressUuid) {
		this.addressUuid = addressUuid;
	}

	public int getHouseNumber() {
		return houseNumber;
	}

	public void setHouseNumber(int houseNumber) {
		this.houseNumber = houseNumber;
	}

	public String getStreetName() {
		return streetName;
	}

	public void setStreetName(String streetName) {
		this.streetName = streetName;
	}

	public String getModifier() {
		return modifier;
	}

	public void setModifier(String modifier) {
		this.modifier = modifier;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public int getZip() {
		return zip;
	}

	public void setZip(int zip) {
		this.zip = zip;
	}

	public String getCommonName() {
		return commonName;
	}

	public void setCommonName(String commonName) {
		this.commonName = commonName;
	}

	public String getExtraString() {
		return extraString;
	}

	public void setExtraString(String extraString) {
		this.extraString = extraString;
	}

	@Override
	public String getPrimaryKey() {
	    return (this.houseNumber + this.streetName + this.modifier + this.zip).toLowerCase();
	}
	
	@Override
	public int compareTo(Address address) {
	    if (this == address) {
	        return 0;
	    }
	    
	    String otherPrimaryKey = address.getPrimaryKey();
	    String thisPrimaryKey = this.getPrimaryKey();
	    
	    return thisPrimaryKey.compareTo(otherPrimaryKey);
	}
	
	@Override
	public String toString() {
	    return "Address: " + this.houseNumber + " " + this.streetName + " " + this.modifier + " " + this.zip;
	}

}
